﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ePioneer_web_ep_question_index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {  
        if (!IsPostBack)
        {
            bd(1);
        }
    }

    private void bd(int page)
    {
        //类别
        int iTid = 1;
        //是否解决
        int iSid = 1;
        try
        {
            if (Request["tid"] != null && Request["tid"] != "")
            {
                iTid = Convert.ToInt32(Request["tid"]);
            }
            if (Request["sid"] != null && Request["sid"] != "")
            {
                iSid = Convert.ToInt32(Request["sid"]);
            }
        }
        catch
        {
            Response.Write("<script>this.history.back(-1);</script>");
            Response.End();
        }
        //this.type_2.Attributes.Add("style", "color:black");
        //this.type_1.Attributes.Add("style", "");
           
        this.hid_questiontype.Value = iTid.ToString();
        this.hid_questionsolve.Value  = iSid.ToString();

        //CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
        //var qlist = dal.ePioneer_Question.Where(x => x.tid == iTid && x.IsClose== iSid);

        string cmsService = System.Configuration.ConfigurationManager.ConnectionStrings["CMSService"].ToString();
        cmsService += "ep_question.ashx?action=GetQuestionPage&iTid=" + iTid + "&iSid=" + iSid;
        var qlist = UrlGet.GetObject<List<ePioneer_Question>>(cmsService);
        AspNetPager1.RecordCount = qlist.Count;
        AspNetPager1.CurrentPageIndex = page;
       
        qlist = qlist.OrderByDescending(x => x.CreateDate).Skip((page - 1) * AspNetPager1.PageSize).Take(AspNetPager1.PageSize).ToList();
        Repeater1.DataSource = qlist;
        Repeater1.DataBind();
         
    }

   


    public int GetPage()
    {
        return AspNetPager1.CurrentPageIndex;
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bd(AspNetPager1.CurrentPageIndex);
    }
}